#include "common.hpp"

int main(int argc, char *argv[])
{
    // 最大设置为32GB的
    uint64_t data_size = (uint64_t)20 * GB / sizeof(float);
    // 设置测试的设备ID为0
    uint32_t device_id = 0;
    // 设置测试的次数
    uint64_t n_loop = 1000;

    float *srcBuff;
    float *dstBuff;
    aclrtStream stream;
    ACLCHECK(aclrtSetDevice(device_id));
    ACLCHECK(aclrtCreateStream(&stream));
    ACLCHECK(aclrtMalloc((void **)&srcBuff, data_size * sizeof(float), ACL_MEM_MALLOC_HUGE_FIRST));
    ACLCHECK(aclrtMallocHost((void **)&dstBuff, data_size * sizeof(float)));
    for (int i = 0; i < n_loop; i++)
    {
        ACLCHECK(aclrtMemcpyAsync(dstBuff, data_size, srcBuff, data_size, ACL_MEMCPY_DEVICE_TO_HOST, stream));
    }
    ACLCHECK(aclrtSynchronizeStream(stream));
    ACLCHECK(aclFinalize());
    return 0;
}
